<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml"> 
 
<head> 
	<meta http-equiv="Content-type" content="text/html; charset=utf-8" /> 
	<title>湖南省自来水公司营销管理信息系统</title> 
	
	<link rel="stylesheet" href="../css/reset.css" type="text/css" media="screen" title="no title" />
	<link rel="stylesheet" href="../css/text.css" type="text/css" media="screen" title="no title" />
	<link rel="stylesheet" href="../css/form.css" type="text/css" media="screen" title="no title" />
	<link rel="stylesheet" href="../css/buttons.css" type="text/css" media="screen" title="no title" />
	<link rel="stylesheet" href="../css/grid.css" type="text/css" media="screen" title="no title" />	
	<link rel="stylesheet" href="../css/layout.css" type="text/css" media="screen" title="no title" />	
	
	<link rel="stylesheet" href="../css/ui-darkness/jquery-ui-1.8.12.custom.css" type="text/css" media="screen" title="no title" />
	<link rel="stylesheet" href="../css/plugin/jquery.visualize.css" type="text/css" media="screen" title="no title" />
	<link rel="stylesheet" href="../css/plugin/facebox.css" type="text/css" media="screen" title="no title" />
	<link rel="stylesheet" href="../css/plugin/uniform.default.css" type="text/css" media="screen" title="no title" />
	<link rel="stylesheet" href="../css/plugin/dataTables.css" type="text/css" media="screen" title="no title" />
	
	<link rel="stylesheet" href="../css/custom.css" type="text/css" media="screen" title="no title">
	<script src="../js/jquery/jquery-3.3.1.js"></script>
</head> 
 
<body> 

<div id="wrapper">	
	
	<div id="bool"><script>window.onload=function (){  $("#bool").load("../ming.html");}</script></div>


	
	<div id="content" class="xgrid">
		
 		
		<div class="x12">
			
			<h2>发票交票</h2>
			
			<div class="form label-inline uniform">
	
				<div class="field"><label for="ArchiveDate">交票时间</label> <input id="ArchiveDate" name="fname" size="50" type="text" class="medium" disabled="disabled"  /></div>
				
				<div class="field"><label for="EmpNmae">交票人</label> <input id="EmpNmae" name="lname" v-model="vv.EmpNmae" size="50" type="text" class="medium" disabled="disabled" placeholder="输入发票号码后，Ajax查询显示" />
                        <input type="hidden" v-model="IvArchive.EmpID" name="EmpID" id="EmpID" />
                </div>
				
				<div class="field"><label for="aname">收票人</label> <input id="aname" name="lname"  size="50" type="text" class="medium" disabled="disabled" value="诸葛发财" /></div>
				<input id="ArchiveEmpID" type="hidden" v-model="IvArchive.ArchiveEmpID">
				<div class="field"><label for="InvoiceType">发票类型</label> <input id="InvoiceType" name="lname" v-model="vv.InvoiceType" size="50" type="text" class="medium" disabled="disabled" placeholder="填入发票号码后，Ajax查询" />
                        <input type="hidden" name="InID" id="InID" v-model="IvArchive.InID"/>
                </div>
				
				<div class="field"><label for="StartNo">发票起始号码</label> <input id="StartNo" name="lname" v-model="IvArchive.StartNo" @change="queryStarNo()" size="50" type="text" class="medium" /></div>
				
				<div class="field"><label for="EndNo">发票终止号码</label> <input id="EndNo" name="lname" onchange="fp()" @change="fptype()" v-model="IvArchive.EndNo" size="50" type="text" class="medium"/></div>
				
				<div class="field"><label for="ArCounts">发票张数</label> <input id="ArCounts" name="lname" v-model="IvArchive.ArCounts" size="50" type="text" class="medium" disabled="disabled" placeholder="填入发票号码后，动态显示" /></div>

                <script>
                    function fp() {
                        var StartNo=$("#StartNo").val();
                        var EndNo=$("#EndNo").val();
                        var kool=EndNo-StartNo+1;
                        if(kool<=1){
                            swal(
                                '终止号码必须大于初始号码!',
                                'warning!',
                                'warning'
                            )
                            kool=null;
                        }
                        $("#ArCounts").val(kool);
                        content.IvArchive.ArCounts=kool;
                    }
                </script>

				<div class="buttonrow">
					<button class="btn" @click="add()" >保存</button>
					<button class="btn btn-grey" onClick="history.back(-1);">返回</button>
				</div>

			</div>
			
		</div> <!-- .x12 -->
		
	</div> <!-- #content -->

	
</div> <!-- #wrapper -->

<script src="../js/jquery/jquery-1.5.2.min.js"></script>
<script src="../js/jquery/jquery-ui-1.8.12.custom.min.js"></script>
<script src="../js/misc/excanvas.min.js"></script>
<script src="../js/jquery/facebox.js"></script>
<script src="../js/jquery/jquery.visualize.js"></script>
<script src="../js/jquery/jquery.dataTables.min.js"></script>
<script src="../js/jquery/jquery.tablesorter.min.js"></script>
<script src="../js/jquery/jquery.uniform.min.js"></script>
<script src="../js/jquery/jquery.placeholder.min.js"></script>

<script src="../js/widgets.js"></script>
<script src="../js/dashboard.js"></script>
<script src="../js/vue.js"></script>

<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>

<script>
    function tools() {
        var date= new Date();
        var time =date.getFullYear()+"-"+(date.getMonth()+1)+"-"+(date.getDay()+13)+"  "+date.getHours()+":"+date.getMinutes()+":"+date.getSeconds()
        $("#ArchiveDate").val(time)
    }
    window.onload=function(){
        window.setInterval(tools,500);

    }
</script>

<script>

    function ff() {
        $.post("/getArID",{},function (str) {
            // alert(str)
        })
    }

    var content=new Vue({
        el:"#wrapper",
        data:{
            ivs:'', //IvArchive集合
            IvArchive:{
                EmpID:'',
                InID:'',
                StartNo:'',
                EndNo:'',
                ArCounts:'',
                ArchiveEmpID:'1',
            },
            iv:'',
            vv:{
                InvoiceType:''
            }
        },
        methods:{
            queryStarNo(){
                var StartNo=$("#StartNo").val();
                $.post("/iv-Ar-StartNo",{"StartNo":StartNo},function (str) {
                    if(str==1){
                        swal(
                            '发票可以交票!',
                            'success!',
                            'success'
                        )
                    }else{
                        swal(
                            '发票不能交票!',
                            'error!',
                            'error'
                        )
                    }
                })
            },
            fptype(){
                $.post("/FPJP_FPLX",this.IvArchive,function (str) {
                    var arr = str.split(",");
                    //alert(arr[0]);
                    //alert(arr[1]);
                    //alert(arr[2]);
                    //alert(arr[3])
                    if(str=="普通发票"){
                        $("#InvoiceType").val();
                        content.vv.InvoiceType=arr[0];
                    }else{
                        $("#InvoiceType").val();
                        content.vv.InvoiceType=arr[0];
                        content.IvArchive.InID=arr[1];
                        content.IvArchive.EmpID=arr[2];
                        content.vv.EmpNmae=arr[3];
                    }

                });
            },
            add(){
                //alert(JSON.stringify(this.IvArchive));
                $.post("/iv-Aradd",this.IvArchive,function (str) {
                    if(str!=0){
                        swal(
                            '交票成功!',
                            'success!',
                            'success'
                        )
                        ff();
                        setTimeout("javascript:location.href='inv_invoiceManage.html'", 1000);
                    }else{
                        swal(
                            '交票失败!',
                            'error!',
                            'error'
                        )
                    }

                })
            },
        },
		created() {
			$(function(){
				$("#bool").load("../ming.html");
				setTimeout(function(){
					$("#aname").val(ming.Syemp.empNmae)
					$("#ArchiveEmpID").val(ming.Syemp.id)
				},100)
			})
		},
    });

</script>


</body> 
 
</html>